﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using ABP.wms.Configuration;
using ABP.wms.Web;

namespace ABP.wms.EntityFrameworkCore
{
    /* This class is needed to run "dotnet ef ..." commands from command line on development. Not used anywhere else */
    public class wmsDbContextFactory : IDesignTimeDbContextFactory<wmsDbContext>
    {
        public wmsDbContext CreateDbContext(string[] args)
        {
            var builder = new DbContextOptionsBuilder<wmsDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            wmsDbContextConfigurer.Configure(builder, configuration.GetConnectionString(wmsConsts.ConnectionStringName));

            return new wmsDbContext(builder.Options);
        }
    }
}
